package edu.wuster.blog.entity;

/*
 * 用户实体类
 * user*/

import edu.wuster.blog.interf.AddGroup;
import edu.wuster.blog.interf.DefaultGroup;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDate;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class User {

    private Integer id;

    @Pattern(regexp = "^([1-9]|[a-z]|[A-Z])(_|[1-9]|[a-z]|[A-Z]){0,14}$", message = "用户名格式错误",groups = AddGroup.class)
    private String username;

    @NotBlank(message = "密码不能为空",groups = AddGroup.class)
    private String password;

    private String gender;

    @Pattern(regexp = "^1[3456789]\\d{9}$", message = "手机号格式错误",groups = DefaultGroup.class)
    private String phone;

    @Pattern(regexp = "^(\\d{6})(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}(\\d|X|x)$", message = "身份证格式错误",groups = DefaultGroup.class)
    private String idNumber;

    private LocalDate createTime;
}
